package de.uni.bremen.estudent.lbs.util;

import com.google.android.maps.GeoPoint;

/**
 * Util class to analyze locations.
 * 
 * @author beni
 * 
 */
public final class LocationAnalyzer {

    /**
     * Set private constructor.
     */
    private LocationAnalyzer() {

    }

    /**
     * Returns true when the location is on campus.
     * 
     * @param location
     *            GeoPoint of location
     * @return returns true if location is on campus
     */
    public static boolean isGeoPointInCampus(GeoPoint location) {
        boolean isGeoPointInCampus = false;
        if (location.getLatitudeE6() >= Constants.GEO_POINT_SOUTH_WEST_ON_CAMPUS
                .getLatitudeE6()
                && location.getLatitudeE6() <= Constants.GEO_POINT_NORTH_EAST_ON_CAMPUS
                        .getLatitudeE6()
                && location.getLongitudeE6() >= Constants.GEO_POINT_SOUTH_WEST_ON_CAMPUS
                        .getLongitudeE6()
                && location.getLongitudeE6() <= Constants.GEO_POINT_NORTH_EAST_ON_CAMPUS
                        .getLongitudeE6()) {
            isGeoPointInCampus = true;
        }
        return isGeoPointInCampus;
    }

    /**
     * Returns true when the location is on campus.
     * 
     * @param latitude
     *            Latitude value
     * @param longitude
     *            Longitude value
     * @return returns true if location is on campus
     */
    public static boolean isGeoPointInCampus(double latitude, double longitude) {
        boolean isGeoPointInCampus = false;
        if (latitude >= Constants.COORDINATES_SOUTH_WEST_ON_CAMPUS[0]
                && latitude <= Constants.COORDINATES_NORTH_EAST_ON_CAMPUS[0]
                && longitude >= Constants.COORDINATES_SOUTH_WEST_ON_CAMPUS[1]
                && longitude <= Constants.COORDINATES_NORTH_EAST_ON_CAMPUS[1]) {
            isGeoPointInCampus = true;
        }
        return isGeoPointInCampus;
    }
}
